<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>BOM</title>
</head>

<body>
<button onclick="clearTime()">使setTimeout失效</button>

<script type="text/javascript">
    function clearTime(){
        clearTimeout(timeout) ;
    }
</script>

<script>
    let timeout = setTimeout( function(){
        console.log( "setTimeout执行了") ;
    } , 5000) ;
    console.log( timeout ) ;
</script>

</body>
</html>